//2
import server from '../server/http'


//请求接口
//resolve解决  reject拒绝

//获取分类的结构
var getType = function(){
    return new Promise((resolve,reject)=>{
        server.get('/fenlei.json').then(res=>{
            resolve(res)
        })
    })
}


//获取列表数据
var getList = function(){
    return new Promise((resolve,reject)=>{
        server.get('/list.json').then(res=>{
            resolve(res)
        })
    })
}

// 获取详情数据
//通过展示页面传过来的a(商品id)进行查找
var getXqlist = function(a) {
    return new Promise((resolve, reject) => {
        server.get('/list.json').then(res => {
            var b=res.data.result
            for(var i in  b) {
                if(b[i]._id == a) {
                    resolve(b[i])
                    break
                }
            }
        })
    })
}

//登录接口
var getLogin = async function(params){
     var result = await server({
        url: 'https://api.it120.cc/small4/user/m/login?deviceId=007&deviceName=monkey',
        method:'post',
        params:params,
    });
var {data} = result
return Promise.resolve(data)
}

//导出api请求方法
export{getType,getList,getXqlist,getLogin}